<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>可变参数累加器</title>
</head>

<body>

	<p> 可变参数累加器</p>
	<p id="demo"></p>	
	<script>

		function sum(...arr) {
			let value = 0;
			for(let i = 0 ; i < arr.length; i++){
				value = value + arr[i];
			}
			return value;
		}


		function sum2() {
			let value = 0;
			for(let i = 0 ; i < arguments.length; i++){
				value += arguments[i];
			}
			return value;
		}

		let s = sum2(1,5,4);
		console.log("值为%s",s)
	</script>

</body>

</html>